<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>css的margin塌陷问题</title>
    <style>
      .outer {
        background-color: red;
        width: 400px;
        /* 采用overflow: hidden; 就能解决塌陷问题，W3C历史遗留问题*/
        overflow: hidden;
      }
      .inner1 {
        background-color: green;
        width: 100px;
        height: 100px;
        /* 这行代码会导致外层元素高度塌陷 */
        margin-top: 100px;
      }
      .inner2 {
        background-color: yellow;
        width: 100px;
        height: 100px;
        /* 这行代码会导致外层元素高度塌陷 */
        margin-bottom: 100px;
      }
    </style>
  </head>
  <body>
    <div class="outer">
      <div class="inner1"></div>
      <div class="inner2"></div>
    </div>
    <div>第二行</div>
  </body>
</html>
